#!/bin/bash

echo "build ..."
rm -rf output/*
mkdir -p output

if [ "ci" = $1 ] ; then
    mvn clean compile -pl eladmin-base,eladmin-bundle -am -Dbdgc.skip=false
elif [ "package_web" = $1 ] ; then
    cd eladmin-web
    npm install
    npm run build:prod
    tar -czf dist.tar.gz ./dist
    cp dist.tar.gz ../output
    cd ..
elif [ "package_system" = $1 ] ; then
    mvn clean package -pl eladmin-system -am -Dbdgc.skip=false
    cp eladmin-system/target/eladmin-system.jar ./output
elif [ "package_mock_server" = $1 ] ; then
    mvn clean package -pl eladmin-mock-server -am -Dbdmgc.skip=false
    cp eladmin-mock-server/target/eladmin-mock-server.jar ./output
elif [ "clean_all" = $1 ] ; then
    mvn clean
    rm -rf output
    rm -rf eladmin-bundle/src
    rm -rf eladmin-bundle-mock/src
fi
echo "build done."
